// Created from GenerationTemplate
// For Decisions HL7 Engine
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using System.Reflection;
using DecisionsFramework.Design.Properties;
using Decisions.HL7.Generated.AbstractMessage;
using Decisions.HL7.DataTypes;
using ST = System.String;
using SI = System.String;
using TX = System.String;
using FT = System.String;
using IS = System.String;
using ID = System.String;
using SNM = System.String;

namespace Decisions.HL7.Message
{
    [DataContract]
	public class SQM_S25 : AbstractMessage
    {
		/// Constructor
		public SQM_S25() : base()
        {
			if (MSH != null) {
                MSH.MessageType = new MSG() { MessageCode = "SQM", TriggerEvent = "S25" };
			}
        }

        /// -----------------------------
        /// -----------------------------
		[DataMember]
        [PropertyClassification("QRD",2)]
  	    [HL7Field(HL7Version.v23, 2, HL7Repeat.False, HL7Required.True,"QRD")]
  	    [HL7Field(HL7Version.v231, 2, HL7Repeat.False, HL7Required.True,"QRD")]
  	    [HL7Field(HL7Version.v24, 2, HL7Repeat.False, HL7Required.True,"QRD")]
  	    [HL7Field(HL7Version.v25, 2, HL7Repeat.False, HL7Required.True,"QRD")]
  	    [HL7Field(HL7Version.v251, 2, HL7Repeat.False, HL7Required.True,"QRD")]
  	    [HL7Field(HL7Version.v26, 2, HL7Repeat.False, HL7Required.True,"QRD")]
	    public QRD QRD {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
        [PropertyClassification("QRF",4)]
  	    [HL7Field(HL7Version.v23, 4, HL7Repeat.False, HL7Required.False,"QRF")]
  	    [HL7Field(HL7Version.v231, 4, HL7Repeat.False, HL7Required.False,"QRF")]
  	    [HL7Field(HL7Version.v24, 4, HL7Repeat.False, HL7Required.False,"QRF")]
  	    [HL7Field(HL7Version.v25, 3, HL7Repeat.False, HL7Required.False,"QRF")]
  	    [HL7Field(HL7Version.v251, 3, HL7Repeat.False, HL7Required.False,"QRF")]
  	    [HL7Field(HL7Version.v26, 3, HL7Repeat.False, HL7Required.False,"QRF")]
	    public QRF QRF {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
        [PropertyClassification("REQUEST",6)]
  	    [HL7Field(HL7Version.v23, 6, HL7Repeat.False, HL7Required.False,"REQUEST_SQM_S25")]
  	    [HL7Field(HL7Version.v231, 6, HL7Repeat.False, HL7Required.False,"REQUEST_SQM_S25")]
  	    [HL7Field(HL7Version.v24, 6, HL7Repeat.False, HL7Required.False,"REQUEST_SQM_S25")]
  	    [HL7Field(HL7Version.v25, 4, HL7Repeat.False, HL7Required.False,"REQUEST_SQM_S25")]
  	    [HL7Field(HL7Version.v251, 4, HL7Repeat.False, HL7Required.False,"REQUEST_SQM_S25")]
  	    [HL7Field(HL7Version.v26, 4, HL7Repeat.False, HL7Required.False,"REQUEST_SQM_S25")]
	    public REQUEST_SQM_S25 REQUEST {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
        [PropertyClassification("PERSONNEL_RESOURCE",32)]
  	    [HL7Field(HL7Version.v23, 32, HL7Repeat.False, HL7Required.False,"PERSONNEL_RESOURCE_SQM_S25")]
  	    [HL7Field(HL7Version.v231, 32, HL7Repeat.False, HL7Required.False,"PERSONNEL_RESOURCE_SQM_S25")]
  	    [HL7Field(HL7Version.v24, 32, HL7Repeat.False, HL7Required.False,"PERSONNEL_RESOURCE_SQM_S25")]
	    public PERSONNEL_RESOURCE_SQM_S25 PERSONNEL_RESOURCE {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
        [PropertyClassification("LOCATION_RESOURCE",40)]
  	    [HL7Field(HL7Version.v23, 40, HL7Repeat.False, HL7Required.False,"LOCATION_RESOURCE_SQM_S25")]
  	    [HL7Field(HL7Version.v231, 40, HL7Repeat.False, HL7Required.False,"LOCATION_RESOURCE_SQM_S25")]
  	    [HL7Field(HL7Version.v24, 40, HL7Repeat.False, HL7Required.False,"LOCATION_RESOURCE_SQM_S25")]
	    public LOCATION_RESOURCE_SQM_S25 LOCATION_RESOURCE {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
        [PropertyClassification("DSC",51)]
  	    [HL7Field(HL7Version.v23, 51, HL7Repeat.False, HL7Required.False,"DSC")]
  	    [HL7Field(HL7Version.v231, 51, HL7Repeat.False, HL7Required.False,"DSC")]
  	    [HL7Field(HL7Version.v24, 51, HL7Repeat.False, HL7Required.False,"DSC")]
  	    [HL7Field(HL7Version.v25, 32, HL7Repeat.False, HL7Required.False,"DSC")]
  	    [HL7Field(HL7Version.v251, 28, HL7Repeat.False, HL7Required.False,"DSC")]
  	    [HL7Field(HL7Version.v26, 32, HL7Repeat.False, HL7Required.False,"DSC")]
	    public DSC DSC {get;set;}



		#region Parser Helpers and Conrete Impls

        internal override Stack<string> ConsumeTextSegments(Stack<string> availableData, HL7ParserOptions options) {

				if (HL7Version.v23 == options.Version) {
		 QRD = PopSegmentParseAndCheckRequired<QRD>(availableData, options, "QRD");
		 QRF = PopSegmentParseAndCheckRequired<QRF>(availableData, options, "QRF");
		 REQUEST = ProcessGroup<REQUEST_SQM_S25>(availableData, options, "REQUEST");
		 PERSONNEL_RESOURCE = ProcessGroup<PERSONNEL_RESOURCE_SQM_S25>(availableData, options, "PERSONNEL_RESOURCE");
		 LOCATION_RESOURCE = ProcessGroup<LOCATION_RESOURCE_SQM_S25>(availableData, options, "LOCATION_RESOURCE");
		 DSC = PopSegmentParseAndCheckRequired<DSC>(availableData, options, "DSC");
		}
		if (HL7Version.v231 == options.Version) {
		 QRD = PopSegmentParseAndCheckRequired<QRD>(availableData, options, "QRD");
		 QRF = PopSegmentParseAndCheckRequired<QRF>(availableData, options, "QRF");
		 REQUEST = ProcessGroup<REQUEST_SQM_S25>(availableData, options, "REQUEST");
		 PERSONNEL_RESOURCE = ProcessGroup<PERSONNEL_RESOURCE_SQM_S25>(availableData, options, "PERSONNEL_RESOURCE");
		 LOCATION_RESOURCE = ProcessGroup<LOCATION_RESOURCE_SQM_S25>(availableData, options, "LOCATION_RESOURCE");
		 DSC = PopSegmentParseAndCheckRequired<DSC>(availableData, options, "DSC");
		}
		if (HL7Version.v24 == options.Version) {
		 QRD = PopSegmentParseAndCheckRequired<QRD>(availableData, options, "QRD");
		 QRF = PopSegmentParseAndCheckRequired<QRF>(availableData, options, "QRF");
		 REQUEST = ProcessGroup<REQUEST_SQM_S25>(availableData, options, "REQUEST");
		 PERSONNEL_RESOURCE = ProcessGroup<PERSONNEL_RESOURCE_SQM_S25>(availableData, options, "PERSONNEL_RESOURCE");
		 LOCATION_RESOURCE = ProcessGroup<LOCATION_RESOURCE_SQM_S25>(availableData, options, "LOCATION_RESOURCE");
		 DSC = PopSegmentParseAndCheckRequired<DSC>(availableData, options, "DSC");
		}
		if (HL7Version.v25 == options.Version) {
		 QRD = PopSegmentParseAndCheckRequired<QRD>(availableData, options, "QRD");
		 QRF = PopSegmentParseAndCheckRequired<QRF>(availableData, options, "QRF");
		 REQUEST = ProcessGroup<REQUEST_SQM_S25>(availableData, options, "REQUEST");
		 DSC = PopSegmentParseAndCheckRequired<DSC>(availableData, options, "DSC");
		}
		if (HL7Version.v251 == options.Version) {
		 QRD = PopSegmentParseAndCheckRequired<QRD>(availableData, options, "QRD");
		 QRF = PopSegmentParseAndCheckRequired<QRF>(availableData, options, "QRF");
		 REQUEST = ProcessGroup<REQUEST_SQM_S25>(availableData, options, "REQUEST");
		 DSC = PopSegmentParseAndCheckRequired<DSC>(availableData, options, "DSC");
		}
		if (HL7Version.v26 == options.Version) {
		 QRD = PopSegmentParseAndCheckRequired<QRD>(availableData, options, "QRD");
		 QRF = PopSegmentParseAndCheckRequired<QRF>(availableData, options, "QRF");
		 REQUEST = ProcessGroup<REQUEST_SQM_S25>(availableData, options, "REQUEST");
		 DSC = PopSegmentParseAndCheckRequired<DSC>(availableData, options, "DSC");
		}
			if (availableData != null && availableData.Count > 0) {
				ConsumeZSegmentsFromText(availableData, options);
			}
            return availableData;
        
        }

        private static Dictionary<string, bool> SEGMENT_VERSION_REQUIRED_MAP = new Dictionary<string, bool>();

		protected override Dictionary<string, bool> MAP_OF_SEGMENT_TO_REQUIRED
        {
            get
			{
				return SEGMENT_VERSION_REQUIRED_MAP;
			}
        }

		public override string HL7ENTITY_TYPE_NAME
        {
            get {
				return "SQM_S25";
			}
        }

        static SQM_S25() {

             SetupStaticPropertyMap(SEGMENT_VERSION_REQUIRED_MAP, typeof(SQM_S25));

        }

		#endregion

		public override string GetER7(HL7ParserOptions options)
		{
			List<string> segmentData = new List<string>();
			if (MSH != null) {
				segmentData.Add(MSH.GetER7(options));
			}
			if (QRD != null) {
				segmentData.Add(QRD.GetER7(options));
			}
			if (QRF != null) {
				segmentData.Add(QRF.GetER7(options));
			}
			if (REQUEST != null) {
				segmentData.Add(REQUEST.GetER7(options));
			}
			if (PERSONNEL_RESOURCE != null) {
				segmentData.Add(PERSONNEL_RESOURCE.GetER7(options));
			}
			if (LOCATION_RESOURCE != null) {
				segmentData.Add(LOCATION_RESOURCE.GetER7(options));
			}
			if (DSC != null) {
				segmentData.Add(DSC.GetER7(options));
			}
           segmentData.AddRange(GetZSegmentsER7(options));
		   return string.Join(HL7ParserConstants.SEGMENT_SEPARATOR, segmentData.ToArray());
        
        }


    }
}

